package engine.logic.tips
{
	import engine.data.ModelLocator;
	import engine.data.SceneObject;
	
	import newx.BaseObject;
	import newx.com.config.StaticIni;
	import newx.utils.debug.IO;

	public class ItemMaxTips
	{
		public static const COLOR_TABLE	:Array	=	["","#ffffff'>","#1eff00'>","#0070dd'>","#a335ee'>","#ff8000'>","#e5cc80'>","#ffff00'>"];
		private const TYPE_TABLE	:Array	=	["","Phy","Nature","Mist","Fire","Ice","Holy","Dark"];
//		private const PROP_TABLE1	:Array	=	new Array();
//		private const PROP_TABLE2	:Array	=	new Array();
		private var _addPropObj	:Object ;
		
		public function ItemMaxTips()
		{
//			PROP_TABLE1[1001]	=	"StrAdd";
//			PROP_TABLE1[1002]	=	"DexAdd";
//			PROP_TABLE1[1003]	=	"IngAdd";
//			PROP_TABLE1[1004]	=	"SpiAdd";
//			PROP_TABLE1[1005]	=	"StaAdd";
//			PROP_TABLE1[1006]	=	"MaxHPAdd";
//			PROP_TABLE1[1007]	=	"MaxMPAdd";			
//			PROP_TABLE1[1036]	=	"MagVaMul";
//			PROP_TABLE1[1037]	=	"NatureDefAdd";
//			PROP_TABLE1[1038]	=	"MistDefAdd";
//			PROP_TABLE1[1039]	=	"IceDefAdd";
//			PROP_TABLE1[1040]	=	"FireDefAdd";
//			PROP_TABLE1[1041]	=	"HolyDefAdd";
//			PROP_TABLE1[1042]	=	"DarkDefAdd";
//			
//			PROP_TABLE2[1012]	=	"MeleePowerAdd";
//			PROP_TABLE2[1013]	=	"ShotPowerAdd";
//			PROP_TABLE2[1014]	=	"MagPowerAdd";
//			_addPropObj	 = StaticIni.getIniObj("AddProp");
		}
		
		/**
		 * 
		 * @param configID				：装备id
		 * @param itemHard				：耐久
		 * @param currentConfigIdArr	：身上装备
		 * @param isPrice				：货币类型
		 * @param special				：打孔属性
		 * @param bindType				：是否有绑定属性
		 * @param bindStatus
		 * @param holeCount
		 * @param cashShopObj
		 * @return 
		 * 
		 */
		public function getStr(serverObj:BaseObject,
							   currentConfigIdArr:Array,
							   isPrice:Boolean = true,
							   cashShopObj:Object = null):String
		{
			var configID:uint	=	serverObj.CheckProperties("ConfigID")	?	serverObj.GetProperties("ConfigID")	:	
				(serverObj.CheckProperties("NameID")	?	serverObj.GetProperties("NameID")	:	0);
			
			var localObj:Object	=	StaticIni.getIniObj(String(configID));
			
			//合并obj
			var equipObj:BaseObject	=	mergeObj(serverObj,localObj);
			
			//本地装备
			var configObj	: Object	=	StaticIni.getIniObj(String(configID));
			
			var itemHard:String	=	"";
			if(equipObj.CheckProperties("Hardiness"))
			{
				itemHard	=	 equipObj.GetProperties("Hardiness");
			}
			else if(null	!=	configObj["MaxHardiness"])
			{
				itemHard	=	configObj["MaxHardiness"];
			}
			
			var special:Array	=	[];
			
			var len		  :int		=	int( StaticIni.getIniVar("ProTipList","addPropNum") );
			
			for(var k : int = 0; k < len; k++)
			{
				try
				{
					special.push(equipObj.GetProperties("AddPropNo"+k));
				}
				catch(e:Error)
				{
					special.push(0);
				}
			}
			
			var bindType : int 	=	getEquipPro("BindType",equipObj,configObj);
			var bindStatus : int = getEquipPro("BindStatus",equipObj,configObj);
			var holeCount:Number =	getEquipPro("HoleCount",equipObj,configObj);
			
//			var special:Array
//			var isPrice:Boolean	=	equipObj.
			
			
			var str		:String		=	"";
			var temp	:String		=	"";
			var roleObj	:SceneObject=	ModelLocator.getInstance().scene.Role;
			
			//当前人物的爵位
			var nowRank:String	=	roleObj.GetPropertiesEx("PeerageRank");
			//当前人物的城堡地位
			var nowStatus:String	=	roleObj.GetPropertiesEx("CurCastleStatusId")	;
			//爵位等级
			var peerageLevel:int	=	(int(	roleObj.GetPropertiesEx("PeerageLev")	) -1) % 10	+ 1;

			var nameid	:String		=	configObj.NameID;
			var color	:int		=	configObj.Color;

			//是否需要爵位
			var needRank	:String	= StaticIni.getIniVar(configID,"NeedPeerageRank");
			//是否需要城堡地位
			var needStatus	:String	= StaticIni.getIniVar(configID,"NeedCastleStatus");
			
			//物品需要爵位等级
			var needPLevel	:int	= (int(StaticIni.getIniVar(configID,"NeedPeerageLev") )-1) % 10	+ 1;
			
			//当前物品的类型
			
			var itmpType:String	=	StaticIni.getIniVar(configID,"ItemType")

			str	= 	StaticIni.getSwfLangStr(nameid);

			str	= 	link_color(str,color);
			
			//是否要显示可打孔
			var holeCountStr:String	=	"";
			if(itmpType	=="105" || itmpType	=="107")
			{
				if(holeCount <4){
					//可打孔
					holeCountStr	=	StaticIni.getSwfLangStr("F_Gem_13233");
				}else{
					//孔以打满
					holeCountStr	=	StaticIni.getSwfLangStr("F_Gem_13242");
				}
				str	=	str.concat(holeCountStr);
			}
			
			//显示是否需要强化
			if(equipObj &&	equipObj.CheckProperties("IntensityType") && 0 != int(equipObj.GetProperties("IntensityType")))
			{
				var intensityLevel:int	=	equipObj.CheckProperties("IntensityLevel") ? equipObj.GetProperties("IntensityLevel") : 0;
				
				if(intensityLevel	<= 0)
				{
					//可强化
					str	=	str.concat("&nbsp;&nbsp;&nbsp;&nbsp;"+ StaticIni.getSwfLangStr("UIStr_1001346") );
				}
				else if(intensityLevel	>=	100)
				{
					//已强化至顶级
					str	=	str.concat("&nbsp;&nbsp;&nbsp;&nbsp;"+ StaticIni.getSwfLangStr("UIStr_1001347") );
				}
				else
				{
					//强化等级
					str	=	str.concat("&nbsp;&nbsp;&nbsp;&nbsp;"+ StaticIni.getSwfLangStrVar("Upgrade_Level",[intensityLevel]) );
				}
				str	=	str.concat("<br>");
				
				//显示装备战斗力
				str = str.concat( getEquipFightScore( serverObj, configID ) + "<br>" );	
				//装备可强化最高等级
				//var MaxUpLevel:int		=	equipObj.CheckProperties("IntensityMaxLevel") ? equipObj.GetProperties("IntensityMaxLevel") : 0;
				var MaxUpLevel:String	=	StaticIni.getIniVar(configID,"IntensityMaxLevel");
				str	=	str.concat(StaticIni.getSwfLangStrVar("Upgrade_Tips_1",[MaxUpLevel]) );
			}else
			{
				//显示装备战斗力
				str = str.concat( "<br>" + getEquipFightScore( serverObj, configID ) );	
			}
			str	=	str.concat("<br>");
			
			//商城物品信息
			str	=	str.concat(cashShopStr(cashShopObj));
			//装备绑定
			var equitStr : String = equipBind(bindType, bindStatus) ;
			if(equitStr != "") equitStr	=	equitStr.concat("<br>");
			str =	str.concat(equitStr);
			
			//装备类型
			var equiptype:String	= configObj.EquipType;
			if(equiptype == "Adorn" || equiptype == "Ring")
			{
				//如果是饰品
				if(!configObj.hasOwnProperty("CantEquipMore"))
				{
					configObj.CantEquipMore	=	0;
				}				
				temp	= StaticIni.getSwfLangStrVar("EquipTypeDes_"+equiptype,
					[StaticIni.getSwfLangStr(
						"Equip_CantEquipMore_"+configObj.CantEquipMore)]);
			}
			else
			{
				temp	= StaticIni.getSwfLangStr("EquipTypeDes_"+equiptype)
			}
			str						= str.concat(temp);
			str						= str.concat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
			
			//show armortype
			var armortype:String	= configObj.ArmorType;
			temp					= StaticIni.getSwfLangStr("ArmorTypeDes_"+armortype);
			str						= str.concat(temp);
			str						= str.concat("<br>");
			//伤害值
			temp 					= link_damage(configID);
			if(temp != "" && temp != null)
			{
				str = str.concat(temp);
				str = str.concat("<br>");
			}
			
			//show phydef物理防御
			var phydef:String	= configObj.PhyDef;
			
			if(phydef != null && phydef != "")
			{
				temp			= StaticIni.getSwfLangStr("ItemDes_PhyDef");
				str				= str.concat(phydef);
				str				= str.concat(temp);
				str				= str.concat("<br>");
			}
			//==================属性列表  Start=====================================
			str	+=	getEquipProStr(configObj,special,holeCount);
			//==================属性列表  End========================================
			
			//show hardiness
			var	hardiness:String= configObj.MaxHardiness;
			if(itemHard!=null&&itemHard!="")
			{
				temp				= StaticIni.getSwfLangStr("ItemDes_Hardiness");
				str					= str.concat(temp);
				str					= str.concat(itemHard);
			}
			str					= str.concat("/");
			str					= str.concat(hardiness);
			str					= str.concat("<br>");
			//show needlevel
			var needlv:String	= configObj.NeedLevel;
			if(needlv != null && needlv != "")
			{
				temp				= StaticIni.getSwfLangStr("ItemDes_NeedLevel");
				var tmpStr:String	= "";
				tmpStr				= tmpStr.concat(temp);
				tmpStr				= tmpStr.concat(needlv);
				var userLevel:String	=	roleObj.GetPropertiesEx("Level");
				if(userLevel!= null && userLevel != "")
				{
					if(int(userLevel)>=int(needlv))
					{
						str				= str.concat(tmpStr);
					}else{
						str				= str.concat("<font color='#f00000'>"+tmpStr+"</font>");
					}
				}
				str				= str.concat("<br>");
			}
			//show profession
			var prof:String		= configObj.AdaptProfType;
			if(prof != null && prof != "")
			{
				var userProf:String	=	roleObj.GetPropertiesEx("ProfType");
				var profList:Array	=	prof.split(",");
				temp			= StaticIni.getSwfLangStr("AdaptProfType_"+prof);
				if(profList.indexOf(userProf)>-1)
				{
					str				= str.concat(temp);
				}else{
					str				= str.concat("<font color='#f00000'>"+temp+"</font>");
				}
				str				= str.concat("<br>");
			}
			
			//是否需要爵位
			if(needRank != null && needRank != "" && needRank != "0")
			{
//				peerageLevel,needPLevel
				
				var rankStr:String	=	StaticIni.getSwfLangStrVar("PeerageLvel_"+needRank,[needPLevel]);
					//StaticIni.getSwfLangStr("PeerageName_"+ (int(needRank)));
				
				//
				if(		int(nowRank) < int(needRank) ||	
					(int(nowRank) == int(needRank) &&	(peerageLevel<needPLevel))
				)
				{
					str					= str.concat( "<font color='#f00000'>"+StaticIni.getSwfLangStrVar("UIStr_1000879",[rankStr])+"</font>");
				}else{
					str					= str.concat( StaticIni.getSwfLangStrVar("UIStr_1000879",[rankStr]));
				}
				str					= str.concat("<br>");
			}
			//是否需要一定的城堡地位
			if(needStatus != null && needStatus !="" && needStatus != "0")
			{
				var statusStr:String	=	StaticIni.getSwfLangStr("CastleStatus_"+ needStatus);
				if(  (int(nowStatus) > int(needStatus)  )  || nowStatus =="0")
				{
					str						= str	.concat( "<font color='#f00000'>"+StaticIni.getSwfLangStrVar("UIStr_1000880",[statusStr])+"</font>");
				}else
				{
					str						= str	.concat(StaticIni.getSwfLangStrVar("UIStr_1000880",[statusStr]));
				}
				str = str.concat("<br>");	
			}
			
			if(currentConfigIdArr!=null)
			{
			//show set information
				var setno:String	= configObj.SetNo;
				var setcount:String	= configObj.SetCount;
				
				if(setno != null && setno != "" && setcount != null && setcount != "")
				{
					temp			= StaticIni.getSwfLangStr("SetDes_"+setno);
					temp			= temp.concat("("+link_set_count(configObj,currentConfigIdArr)+"/"+setcount+")");
					temp			= link_color(temp,2);
					str             = str.concat(temp);
					str				= str.concat("<br>");
					
					for(var i:uint = 1; i <= int(setcount) ; i ++)
					{
						temp = StaticIni.getSwfLangStr("SetNo_"+setno+"_"+i);
						
						if(get_set_position(setno,i,currentConfigIdArr))
						{
							temp = link_color(temp,2);
						}
						else
						{
							temp = link_color(temp,7);
						}
						
						str  = str.concat(temp);
						
						if(i%2 == 0)
						{
							str = str.concat("<br>");
						}
						else
						{
							str = str.concat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
							if(i == int(setcount))
							{
								str = str.concat("<br>");
							}
						}
					}
					str = str.concat("<br>");
					for(var j:uint = 1 ; j <= 15 ; j ++)
					{
						temp = StaticIni.getSwfLangStr("Description"+j+"_"+setno);
						
						if(temp != "Description"+j+"_"+setno)
						{
							if(j <= link_set_count(configObj,currentConfigIdArr))
							{
								temp = link_color(temp,2);
							}
							str = str.concat(temp)

							str = str.concat("<br>");
						}
					}
				}
			}

			//show description
			var des:String		= configObj.Description;
			if(des != null && des != "")
			{
				temp			= StaticIni.getSwfLangStr("Description_"+configID);
				str				= str.concat(temp + "<br>") ;
			}
			
			var itemTime : String	=	getItemStopTime(equipObj as BaseObject);
			if(itemTime != "")
			{
				str				= str.concat(itemTime) + "<br>";
			}
			
			if(isPrice)
			{
//				var sellPrice:String	= StaticIni.getIniVar(configID,"SellPrice");
//				str = str.concat("<br>");
//				str = str.concat(StaticIni.getSwfLangStr("UIStr_1000296"));
//				str = str.concat(sellPrice);
				
				str = str.concat("<br>");
				
				//卖只能获得金币
				var sellPrice:String		= configObj.SellPrice;
				
				if(int(sellPrice) > 0)
				{
					str = str.concat(StaticIni.getSwfLangStr("UIStr_1000296"));
					str = str.concat(sellPrice);
					str = str.concat(StaticIni.getSwfLangStr("Tips_CapitalType0"));
				}				
			}
			return str;
		}
		/**
		 * 显示商城销售商品信息 
		 * @param val
		 * @return 
		 * 
		 */		
		private function cashShopStr(val:Object):String
		{
			var tempStr:String	=	"";
			if(val != null)
			{
				//原价
				var price:int		=	val["Price"];
				//现价
				var sellprice:int	=	val["Sellprice"];
				//币种
				var cointype:int		=	val["Cointype"]
				//优惠类型
				var type:int			=	val["Type"];
				//优惠信息
				var typeref:int			=	val["Typeref"];
				//限购数量
				var limit:int			=	val["Limit"];
				//单人限购数量
				var personal:int		=	val["Personal"];
				//说明
				var desc:String			=	val["Desc"];
				
				tempStr	=	tempStr.concat(StaticIni.getSwfLangStr("UIStr_1000926") + String(price) + moneyType(cointype) + "<br>");
				tempStr	=	tempStr.concat(sellType(cointype) + String(sellprice) + moneyType(cointype) + "<br>");
				
				switch(type)
				{
					//打折
					case 2:
						tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000961",[StaticIni.getSwfLangStr("UIStr_1000993")]) + "<br>");
						if(typeref > 0)
						{
							tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000962",[StaticIni.getSwfLangStrVar("UIStr_1000997",[typeref])]) + "<br>");			
						}
						break;
					//直降
					case 3:
						tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000961",[StaticIni.getSwfLangStr("UIStr_1000995")]) + "<br>");
						if(typeref > 0)
						{
							tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000962",[typeref + moneyType(cointype)]) + "<br>");
						}	
						break;
					//秒杀
					case 4:
						tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000961",[StaticIni.getSwfLangStr("UIStr_1000994")]) + "<br>");
						if(personal > 0)
						{
							tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000962",[StaticIni.getSwfLangStr("UIStr_1000957")+StaticIni.getSwfLangStrVar("UIStr_1000998",[personal])]) + "<br>");
						}
						break;
					//限量抢购
					case 5:
						tempStr	=	tempStr.concat(StaticIni.getSwfLangStrVar("UIStr_1000961",[StaticIni.getSwfLangStr("UIStr_1001394")]) + "<br>");
						break;
				}
//				if(desc != "" && desc != null &&desc != "11")
//				{
//					tempStr	=	tempStr.concat(desc   + "<br>");
//				}
			}
			return tempStr;
		}
		
		/**
		 * 优惠类型字符
		 * @param val
		 * @return 
		 * 
		 */		
		private function sellType(val:int):String
		{
			var tempStr:String	=	"";
			switch(val){
				case 1:
					tempStr	=	StaticIni.getSwfLangStr("UIStr_1000929");
					break;
				case 2:
					tempStr	=	StaticIni.getSwfLangStr("UIStr_1000927");
					break;
				case 3:
					tempStr	=	StaticIni.getSwfLangStr("UIStr_1000928");
					break;
				case 4:
					tempStr	=	StaticIni.getSwfLangStr("UIStr_1000987");
					break;
				case 5:
					tempStr	=	StaticIni.getSwfLangStr("UIStr_1000988");
					break;
				case 6:
					tempStr	=	StaticIni.getSwfLangStr("UIStr_1000929");
					break;
			}
			return tempStr;
		}
		
		/**
		 * 判断当前物品是否有孔，和当前镶嵌的状态 
		 * @param val
		 * @param configObj
		 * @return
		 * 
		 */		
		private function modiStr(val:Number,holeArray:Array):String
		{
			var tempStr:String	=	"";
			for(var i:int=0;i< 4;i++)
			{
				if(i < val)
				{
					tempStr	=	tempStr.concat(modiTitle(i));
					tempStr	=	tempStr.concat(modiInfor(i,holeArray));
					tempStr	=	tempStr.concat("<br>")
				}	
			}
			return tempStr;
		}
		private function modiTitle(val:int):String
		{
			var tempStr:String="";
			switch (val)
			{
				case 0:
					tempStr	=	StaticIni.getSwfLangStr("F_Gem_13229");
					break;
				case 1:
					tempStr	=	StaticIni.getSwfLangStr("F_Gem_13230");
					break;
				case 2:
					tempStr	=	StaticIni.getSwfLangStr("F_Gem_13231");
					break;
				case 3:
					tempStr	=	StaticIni.getSwfLangStr("F_Gem_13232");
					break;
			}
			return tempStr;
		}
		private function modiInfor(val:Number,holeArray:Array):String
		{
			var tempStr:String	=	"";
			var property	:String	=	"";
			if(val != -1 && holeArray!=null)
			{
				property	= holeArray[val];
				if(property != null && property != ""&&property !="0")
				{
					var propertyList : Array	=	_addPropObj[property].split(",");
					//属性类型
					var type : String = propertyList[3];
					//属性值
					var value : int = propertyList[4];
					
					//有属性的时候
					if(type != null && type != "")
					{
						tempStr 	= StaticIni.getSwfLangStrVar("Item_" + type,[value]);
					}
				}
				else
				{
					tempStr	=	StaticIni.getSwfLangStr("F_Gem_13234");
				}
			}
			else
			{
				tempStr	=	StaticIni.getSwfLangStr("F_Gem_13233");
			}
			tempStr = 	link_color(tempStr,7);
			return tempStr;
		}
		
		/**
		 *	装备是否bind 
		 * @return 
		 * 
		 */
		private function equipBind(bindType : int, bindStatus : int) : String
		{
			//没有绑定类型，说明不需要显示
			var t:int = 0;
			if(bindType == 0) return "";
			
			//已经绑定
			if(bindStatus == 1) return StaticIni.getSwfLangStr("BindStatus_1");
		
			return StaticIni.getSwfLangStr("BindType_" + bindType);
		}
		
		/**
		 *	装备属性(特殊属性，随机属性,等) 
		 * @param configObj
		 * @param special
		 * @return 
		 * 
		 */
		private function  link_common_property(configObj:Object, special:Array):String
		{
			//颜色
			var color		:int	=	configObj.Color;
			var tips		:String	=	"";
			var property	:String	=	"";
			
			for(var i:uint = 0 ; i <= 5 ; i ++)
			{
				//获取属性
				property	= special == null ? configObj["AddPropNo"+i] : special[i];
				//当有属性的时候
				if(property != null && property != "" && property != "0")
				{
					tips = tips.concat(equipProperty(color, _addPropObj[property]));
				}
			}
			
			return tips + "<br>";
		}
		
		/**
		 * 	单一属性
		 * @param color				颜色
		 * @param property			属性
		 * @return 
		 * 
		 */
		private function equipProperty(color : int, property : String) : String
		{
			var tips : String = "";
			//属性obj
			var propertyList : Array	=	property.split(",");
			//属性类型
			var type : String = propertyList[3];
			//属性值
			var value : int = propertyList[4];
			
			//有属性的时候
			if(type != null && type != "")
			{
				//加颜色
				tips 	= tips.concat(link_color(StaticIni.getSwfLangStrVar("Item_" + type,[value]), color));
				tips 	= tips.concat("<br>");
			}
			return tips;
		}
		
//		/**
//		 *	装备特殊属性 
//		 * @param configObj
//		 * @param special
//		 * @return 
//		 * 
//		 */
//		private function link_common_property_other(configObj:Object,special:Array):String
//		{
//			var color		:String	=	configObj.Color;
//			var str			:String	=	"";
//			var temp		:String	=	"";
//			var temp1		:int;
//			var temp2		:int;
//			var property	:String	=	"";
//			
//			var type		:String	=	"";
//			
//			for(var i:uint = 0 ; i <= 5 ; i ++)
//			{
//				property	= special[i];
//				if(property != null && property != "")
//				{
//					temp1	=	int(Number(property)/1000);
//					temp2	=	Number(property)%1000;
//					
//					if(!_addPropObj.hasOwnProperty(property)) continue;
//					var tmpValList:Array	=	_addPropObj[property].split(",");
//					temp2	=	tmpValList[4];
//					
//					type	=	StaticIni.getIniVar("AddProp_type_com","type_"+temp1);
//					
//					if(type != null && type != "")
//					{
//						temp 	= StaticIni.getSwfLangStrVar("Item_"+type,[temp2]);
//						temp 	= link_color(temp,int(color));
//						str  	= str.concat(temp);
//						str 	= str.concat("<br>");
//					}
//				}
//			}
//			return str;
//		}
		
		private function  get_set_position(setno:String,number:int,item_table:Array):Boolean
		{
			var tSize	:int	=	item_table.length;
			var temp1	:String	=	"";
			var temp2	:String	=	"";
			
			for(var i:uint = 0 ; i < tSize ; i++)
			{
				temp1 = StaticIni.getIniVar(item_table[i],"SetNo");
				temp2 = StaticIni.getIniVar(item_table[i],"SetPos");
				
				if(temp1 == setno && temp2 == String(number))
				{
					return true;
				}
			}
			
			return false;
		}
		
		private function link_set_count(configObj:Object,item_table:Array):int
		{
			var setno	:String	= 	configObj.SetNo;
			var count	:int	= 	0;
			var tSize	:int	=	item_table.length;
			var temp	:String	=	"";
			
			for(var i:uint = 0 ; i < tSize ; i++)
			{
				temp = StaticIni.getIniVar(item_table[i],"SetNo");
				if(temp == setno)
				{
					count++;
				}
			}
			
			return count;
		}
		
		
//		private function	link_spec_property(configID:uint):String
//		{
//			var color		:String	=	StaticIni.getIniVar(configID,"Color");
//			var str			:String	=	"";
//			var temp		:String	=	"";
//			var temp1		:int;
//			var temp2		:int;
//			var property	:String	=	"";
//			
//			var type		:String	=	"";
//			
//			for(var i:uint = 0 ; i <= 5 ; i ++)
//			{
//				property	= 	StaticIni.getIniVar(configID,"AddPropNo"+i);
//				temp		=	"";
//				if(property != null && property != "")
//				{
//					temp1	=	int(Number(property)/1000);
//					temp2	=	Number(property)%1000;
//					
//					if(!_addPropObj.hasOwnProperty(property)) continue;
//					var tmpValList:Array	=	_addPropObj[property].split(",");
//					temp2	=	tmpValList[4];
//					
//					type	=	StaticIni.getIniVar("AddProp_type_spc","type_"+temp1);
//					
////					if(PROP_TABLE2[temp1] != null)
//					if(type != null && type != "")
//					{
////						temp 	= temp.concat(StaticIni.getSwfLangStr("ItemDes_Prop_"+type));
//						temp 	= StaticIni.getSwfLangStrVar("Item_"+type,[temp2]);
////						temp 	= temp.concat(temp2);
////						temp 	= temp.concat(".");
//						temp 	= link_color(temp,int(color));
//						str  	= str.concat(temp);
//						str  	= str.concat("<br>");
//					}
//				}
//			}
//			return str;
//		}
		
		
		private function link_damage(configID:uint):String
		{
			var temp		:String = 	"";
			var str			:String = 	"";
			var tSize		:uint	=	TYPE_TABLE.length;
			
			var mindamage	:String = 	"";
			var maxdamage	:String = 	"";
			
			var tObj		:Object	=	StaticIni.getIniObj(String(configID));
			
			for(var i:uint = 1 ; i< tSize ; i ++)
			{
				mindamage	=	tObj["Min"+TYPE_TABLE[i]+"Damage"];
				maxdamage	=	tObj["Max"+TYPE_TABLE[i]+"Damage"];
				
				if(maxdamage != null && maxdamage != "" && mindamage != null && mindamage != "")
				{
					str		=	mindamage;
					str		=	str.concat("-");
					str		=	str.concat(maxdamage);					
					temp	=	StaticIni.getSwfLangStr("ItemDes_Damage_"+TYPE_TABLE[i]);
					str 		= str.concat(temp)
					break;
				}
			}
			
			return str;
		}
		/**
		 * 货币类型 
		 * @param val
		 * 
		 */		
		private function moneyType(val:int):String
		{
			var moneyStr:String	=	"";
			switch(val)
			{
				case 0:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType0")
					break;
				case 1:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType1")
					break;
				case 2:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType2")
					break;
				case 3:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType3")
					break;
				case 4:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType4")
					break;
				case 5:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType5")
					break;
				case 6:
					moneyStr	=	StaticIni.getSwfLangStr("Tips_CapitalType6")
					break;
			}
			return moneyStr;
		}
		private function link_color(str:String,color:int):String
		{
			if(color < 1 || color >8)
			{
				color	=	1;
			}
			
			return ("<font color ='"+COLOR_TABLE[color]+str+"</font>");
		}
		
		private function getEquipProStr(equipObj:Object,addProArr:Array,holeCount:int=-1):String
		{	
			if(addProArr == null)
			{
				return link_common_property(equipObj,addProArr);
			}
			
			var str	:String	=	"";
			
			//显示装备属性(特殊属性，随机属性)
			var modifyStr:String=	"";
			//取基础属性数组，方便后面查找
			var baseProArr:Array	=	link_common_property(equipObj,addProArr).split("<br>");
			baseProArr.pop();//弹出最后一个仅含<br>的项
			
//			str 	= str.concat(basePro);
			
			//添加打孔属性
			var chatArray:Array	=	[];
			if(addProArr	!= null && holeCount >0)
			{
				chatArray		=	addProArr.slice(6,10);
				modifyStr		= 	modiStr(holeCount,chatArray);
				modifyStr		=	 modifyStr.concat("<br>");
			}
			//其他属性0,1已经写死了10个属性，6个给基础属性，4个给打孔的
			var residueProStr:String	=	"";
			var tipTypeObj:Object;
			/**{
			var type:int;//该类型属性显示方式 0换行显示,1附到基础属性上显示
			var startNum:int;//开始属性
			var num:int;	//属性数
			var name:String;	//属性类型名
			}*/
			var proList:Array=StaticIni.getIniVar("ProTipList","list").split(",");

			var len:int	=	proList.length;
			for(var i:int=2;	i<len;	i++)//0,1不管
			{
				tipTypeObj	=	StaticIni.getIniObj("ProTipList_"+proList[i]);
				var j:int=0;
				var pro:String;
				var proArr:Array;
				var index:int;
				//加到基础属性后面
				if( 1 ==	int(tipTypeObj.type) )
				{
					for(j=0;	j<int(tipTypeObj.num);	j++)
					{
						pro		=	addProArr[int(tipTypeObj.startNum)+j];
						if(	0	==	int(pro)	)	continue;
						
						proArr	=	_addPropObj[pro].split(",");
						
						index	=	getBaseProIndex(addProArr,proArr[3]);
						if(index	>	-1)
						{
							baseProArr[index] += " (+"+proArr[4]+")";
						}
					}
				}
				else//0另起一行
				{
					
					for(j=0;	j<int(tipTypeObj.num);	j++)
					{
						pro		=	addProArr[int(tipTypeObj.startNum)+j];
						if(	0	==	int(pro)	)	continue;
						proArr	=	_addPropObj[pro].split(",");
										
						residueProStr += StaticIni.getSwfLangStrVar("Item_" + proArr[3],[proArr[4]]) + "<br>";
					}
					
					if("" !=	residueProStr)
						residueProStr = StaticIni.getSwfLangStr(tipTypeObj.name)+"<br>" + residueProStr + "<br><br>";
				}
			}
			
			var basePro:String	=	baseProArr.join("<br>")+"<br>";
			str	=	str.concat(basePro,modifyStr,residueProStr);//基础属性//打孔//强化
//			str.concat(modiStr);
//			str.concat(residueProStr);
			
			return str;
		}
		private function getBaseProIndex(proArr:Array,proStr:String):int
		{	
			for(var i:int=0;	i<6;	i++)
			{
				if(proArr[i] != 0)
				{
					var baseArr:Array = _addPropObj[proArr[i]].split(",");
					if(baseArr[3] == proStr)
					{
						return i;
					}
				}
			}
			
			return -1;
		}
		private function getEquipPro(pName:String,equipObj:BaseObject,localObj:Object):*
		{
			if(equipObj.CheckProperties(pName))
			{
				return equipObj.GetProperties(pName);
			}
			else if(null	!=	localObj[pName])
			{
				return localObj[pName];
			}
			else
			{
				IO.traceLog("Tips一个属性未找到！！！","属性名",pName);
			}
			
			return 0;
		}
		
		//装备消失时间
		private function getItemStopTime(pObj : BaseObject):String
		{
			if(pObj	==	null)return "";
			if(!pObj.CheckProperties("BeginTime")) return "";
			
			//持续时间(小时转化成毫秒)
			var validTime	:	Number	=	pObj.GetProperties("ValidTime") * 60 * 1000;
			if(validTime == 0) return "";
			
			//单位毫秒
			var beginTime	:	Number	=	pObj.GetProperties("BeginTime") * 1000;
			var date : Date	=	new Date(beginTime + validTime);
			
			return StaticIni.getSwfLangStrVar("UIStr_1001353", [date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes()]); 
		}
		
		
		/**
		 * 把本地装备obj合并到网络obj上 
		 * @param serverObj
		 * @param localObj
		 * 
		 */		
		private function mergeObj(serverObj:BaseObject,localObj:Object):BaseObject
		{
			
			var resultObj:BaseObject	=	BaseObject.fromObj(localObj);
			
			serverObj.getDataForEach(function(proName:String,proValue:*):void
			{
				resultObj.HandleProperties(proName,proValue);
			});
			
			return resultObj;
		}
		
		/**
		 *	获取装备战斗力评分 
		 * @return 
		 * 
		 */		
		private function getEquipFightScore( serverObj : BaseObject, configID : int ):String
		{
			var itemFightPower : int = int( StaticIni.getIniVar( configID, "ItemFightPower" ) );
			
//			return StaticIni.getSwfLangStrVar( "FightPower_1", [ int( serverObj.GetProperties( "JewelFightPower" ) )
//				+ int( serverObj.GetProperties( "UpgradeFightPower" ) ) ] );
			
//			//装备基础评分
//			var equitScore 	: String =  StaticIni.getSwfLangStrVar( "FightPower_1", 
//										[ StaticIni.getIniVar( configID, "ItemFightPower" ) ] );
//			//宝石评分
			var jpgradeFightPower 	: int;
			//强化评分
			var jewelFightPower		: int;
//			//附加评分
			var power				: int;
//				
			if( serverObj.CheckProperties( "JewelFightPower" ) )
			{
				//宝石评分
				jpgradeFightPower = int( serverObj.GetProperties( "JewelFightPower" ) );
			}
			if( serverObj.CheckProperties( "UpgradeFightPower" ) )
			{
				//强化评分
				jewelFightPower = int( serverObj.GetProperties( "UpgradeFightPower" ) );
			}
			power = itemFightPower + jpgradeFightPower + jewelFightPower;
			
			return StaticIni.getSwfLangStrVar( "FightPower_1", [ power ] );
			
//			if( 0 == power )
//			{//没有附加评分，只显示基础评分
//				return equitScore;
//			}
//			else
//			{
//				return equitScore +  StaticIni.getSwfLangStrVar( "FightPower_2", [ power ] );
//			}
		}
	}
}